package org.ptraco.pt.login.view
{
	import flash.events.Event;
	
	import mx.controls.Alert;
	
	import org.ptraco.pt.facade.ApplicationNotificationConstants;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;

	public class LoginPanelMediator extends Mediator
	{
		public static const NAME:String = "loginPanelMediator";
		
		public function LoginPanelMediator(viewComp:Object=null)
		{
			super(NAME,viewComp);
		}
		
		public function get loginPanel():LoginPanel{
			return viewComponent as LoginPanel
			
		}
		
		override public function listNotificationInterests():Array{
			
			return [
				ApplicationNotificationConstants.LOGIN_RESULT_NOTIFICATION
			];
			
			
		}
		override public function handleNotification(notification:INotification):void{
			switch(notification.getName()){
				case ApplicationNotificationConstants.LOGIN_RESULT_NOTIFICATION:
				mx.controls.Alert.show("Welcome Sagar");
			}
		}
		
		override public function onRegister():void
		{
			super.onRegister();
			loginPanel.addEventListener(LoginPanel.EVENT_SUBMIT_CLICKED,onSubmit);
		}		
		
		private function onSubmit(event:Event):void{
			//var loginData:Object = event.dataObject as Object;
			sendNotification(ApplicationNotificationConstants.LOGIN_RESULT_NOTIFICATION);
		}
	}
}